package com.want.model.dto;

/**
 * @author WangZhiJian
 * @since 2021/11/21
 */
public class ResultUtil {
    public static  <T>   Result<T> ofSuccess(T t){
        return Result.<T>builder()
                .code(200)
                .data(t)
                .build();
    }
    public static <T> Result<T> ofSuccess(String msg,T t){
        return Result.<T>builder()
                .code(200)
                .msg(msg)
                .data(t)
                .build();
    }

    public static <T> Result<T> ofFail(String msg,Class<T> t){
        return ofFail(500,msg,t);
    }

    public static <T> Result<T> ofNotFound(String msg,Class<T> t){
        return ofFail(404,msg,t);
    }

    public static <T> Result<T> ofFail(Integer code,String msg,Class<T> t){
        return Result.<T>builder()
                .code(code)
                .msg(msg)
                .build();
    }
}
